home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / Utilities / Installer v3.4.3 / Examples - Installer 3.4 / UserFunction Samples / CheckTgtFreeSpace Sample / CheckTgtFreeSpace.c next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  1.6 KB  |  52 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.1 sample: User Functions
  6.  *
  7.  *    File:        UserFunction.c -    c Source
  8.  *
  9.  *    by:            Jon Zap
  10.  *  updated for use with Installer 3.4 by: Rich Kubota 9/1/92
  11.  *
  12.  *    Copyright © 1988-1990 Apple Computer, Inc.
  13.  *    All rights reserved.
  14.  *
  15.  *----------------------------------------------------------------------------*/
  16. #if 0
  17. c -b CheckTgtFreeSpace.c
  18. Link -ra =resPurgeable -rt infn=1001 -rn -m CHECKTGTFREESPACE -t rsrc -c RSED ∂
  19.         CheckTgtFreeSpace.c.o ∂
  20.         "{Libraries}"Interface.o ∂
  21.         -o CheckTgtFreeSpace.rsrc
  22. #endif
  23.  
  24. /* applec is only defined by MPW C so we can use it to make versions that work
  25.   with MPW C and THINK C
  26.  */
  27. #ifdef applec
  28.  
  29. #include    <Files.h>
  30. #endif
  31.  
  32. pascal Boolean CheckTgtFreeSpace(short targetVRefNum, long blessedID, long spaceRequired)
  33. {
  34. #pragma unused (blessedID)
  35.     ParamBlockRec    pb;
  36.     OSErr            err;
  37.     
  38.     pb.volumeParam.ioCompletion = nil;     // synchronous call
  39.     pb.volumeParam.ioNamePtr = nil;        // searching only by vRefNum
  40.     pb.volumeParam.ioVRefNum = targetVRefNum;    // get info on this volume
  41.     pb.volumeParam.ioVolIndex = 0;        // access volume by vRefNum only
  42.     
  43.     // parameter block is set, so let's do it synchronously
  44.     err = PBGetVInfo(&pb, false);
  45.     if (err)
  46.         return false;    // error occured accessing volume, this shouldn't happen
  47.     
  48.     return ( spaceRequired < pb.volumeParam.ioVFrBlk * pb.volumeParam.ioVAlBlkSiz);
  49.     // ioVFrBlk is the number of free allocation blocks on the target disk
  50.     // ioVAlBlkSiz is the number of bytes per allocation block
  51.     // the product of these two values is the amount of free space.
  52. }